export class LTInput {

    public static get instance(): LTInput {
        return this._instance;
    }

    private static _instance: LTInput;

    public static CreateInstance() {
        if (this._instance != null) return;
        this._instance = new LTInput();
    }

    public _cacheInput: boolean[];

    private constructor() {
        Laya.stage.on(Laya.Event.KEY_DOWN, this, this._OnKeyDown);
        Laya.stage.on(Laya.Event.KEY_UP, this, this._OnKeyUp);
        this._cacheInput = [];
    }

    private _OnKeyDown(event: Laya.Event) {
        this._cacheInput[event.keyCode] = true;
    }

    private _OnKeyUp(event: Laya.Event) {
        this._cacheInput[event.keyCode] = false;
    }

    public GetKey(keyCode: number): boolean {
        return !!this._cacheInput[keyCode];
    }

}